<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 写一个可以实现任意数组的去重的“函数”假设有数组["a","b","c","d","a","a","c","d","e","b"]代码去重,得到结果:["a","b","c","d","e"] -->
    <SCript>
        let arr = ["a", "b", "c", "d", "a", "a", "c", "d", "e", "b"]

        function xin(arr) {
            //定义一个新的临时数组 
            let newArr = [];
            //遍历当前数组 
            for (var i = 0; i < arr.length; i++) {
                //如果当前数组的第i已经保存进了临时数组，那么跳过，
                //否则把当前项push到临时数组里面 
                if (newArr.indexOf(arr[i]) === -1) {
                    //indexOf() 判断数组中有没有字符串值，如果没有则返回 -1 
                    newArr.push(arr[i]);
                }
            }
            return newArr
        }
        let arr2 = xin(arr);
        console.log(arr2);
    </SCript>

</body>

</html>